<template>
  <div class="approval">
    <el-card class="box-card" style="margin-top: 110px;">
      <div class="title">{{$t('achievements.title1')}}</div>
      <div class="menu-search">
        <div class="menu-title">
          <!-- APP名称 -->
          <div class="searchItem">
            <span>{{$t('appHelpCenter.appName')}}</span>
            <el-input
              v-model="listQuery.appName"
              :placeholder="$t('creditSupermarket.ruleName')"
              size="small"
            ></el-input>
          </div>
          <!-- 强更状态 -->
          <div class="searchItem">
            <span>{{$t('AppVersion.StrongerState')}}</span>
            <el-select v-model="listQuery.forceStatus" size="small">
              <el-option
                v-for="item in appStatus"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </div>
          <!-- 展期状态 -->
          <div class="searchItem">
            <span>{{$t('AppVersion.ExtensionStatus')}}</span>
            <el-select v-model="listQuery.rolloverStatus" size="small">
              <el-option
                v-for="item in extStatusArr"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </div>
          <div class="menu-title-btn" style="margin-left: 20px;">
            <button type="button" @click="search">{{$t('btn.query')}}</button>
          </div>
        </div>
      </div>
    </el-card>
    <el-card class="box-card" style="margin-top: 10px;margin-bottom: 20px;">
      <div style="display: flex; justify-content: space-between;">
        <div class="title">{{$t('DailyStatistics.ListDetails')}}</div>
        <div class="menu-list">
          <button type="button" @click="handleCreate">{{$t('btn.add')}}</button>
        </div>
      </div>
      <el-table
        v-loading="listLoading"
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%; margin-top: 5px;"
        @selection-change="handleSelectionChange"
        border
        stripe
        size="mini"
      >
        <!-- APP名称 -->
        <el-table-column
          prop="appName"
          align="center"
          header-align="center"
          :label="$t('appHelpCenter.appName')"
          width="160"
        ></el-table-column>
        <!-- 版本号 -->
        <el-table-column
          prop="verId"
          align="center"
          header-align="center"
          :label="$t('AppVersion.verId')"
          width="140">
        </el-table-column>
        <!-- 渠道 -->
        <el-table-column
          prop="channelName"
          align="center"
          header-align="center"
          :label="$t('productManage.channels')"
          width="160"
        ></el-table-column>
        <!-- 订单前缀 -->
        <el-table-column
          prop="appShortName"
          align="center"
          header-align="center"
          :label="$t('AppVersion.OrderPrefix')"
          width="140"
        ></el-table-column>
        <!-- 创建时间 -->
        <el-table-column
          prop="crtTime"
          align="center"
          header-align="center"
          :label="$t('approvalDetail.smsCrtTime')"
          width="160"
        ></el-table-column>
        <!-- 是否展期 -->
        <el-table-column
          header-align="center"
          align="center"
          prop="rolloverStatus"
          width="160"
          :label="$t('AppVersion.isExtension')"
        >
          <template slot-scope="scope">
            <el-radio-group v-model="scope.row.rolloverStatus" size="small" @change.native="changeStatus(scope.row)">
                <el-radio :label="1" size="mini">{{$t("approvalDetail.yes")}}</el-radio>
                <el-radio :label="0" size="mini">{{$t("approvalDetail.no")}}</el-radio>
            </el-radio-group>
          </template>
        </el-table-column>
        <!-- 强更状态 -->
        <el-table-column
          header-align="center"
          align="center"
          prop="forceStatus"
          width="160"
          :label="$t('AppVersion.StrongerState')"
        >
          <template slot-scope="scope">
            <el-radio-group v-model="scope.row.forceStatus" size="small" @change.native="changeStatusUpdate(scope.row)">
                <el-radio :label="1" size="mini">{{$t("AppVersion.enable")}}</el-radio>
                <el-radio :label="0" size="mini">{{$t("AppVersion.blockup")}}</el-radio>
            </el-radio-group>
          </template>
        </el-table-column>
        <!-- 发布状态 -->
        <el-table-column
          header-align="center"
          align="center"
          prop="onlineStatus"
          width="160"
          :label="$t('AppVersion.PublishStatus')"
        >
          <template slot-scope="scope">
            <el-select v-model="scope.row.onlineStatus" size="small" @change="changeStatusPublish(scope.row)">
              <el-option
                v-for="(item, index) in pubStatusArr"
                :key="index"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column align="center" :label="$t('user.operation')" width="260">
          <template slot-scope="scope">
            <!-- 编辑 -->
            <el-button size="small" type="text" @click="handleUpdate(scope.row)">{{$t('btn.edit')}}</el-button>
            <!-- 删除 -->
            <el-button
              size="small"
              type="text"
              @click="handleDelete(scope.row)"
              style="color: #f56c6c;"
            >{{$t('btn.delete')}}</el-button>
            <!-- 版本记录 -->
            <el-button size="small" type="text" @click="hitseeFn(scope.row)">
              {{$t('AppVersion.versionRecord')}}
            </el-button>
            <!-- 下载地址管理 -->
            <el-button size="small" type="text" @click="packageFn(scope.row)">
              {{$t('AppVersion.PackageManage')}}
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-container">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="listQuery.page"
          :page-sizes="[5, 10, 20, 30]"
          :page-size="listQuery.limit"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </el-card>
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :before-close = "closeDialog" width="35%">
      <el-form :model="form" :rules="rules" ref="form" label-width="100px" style="height: 400px; overflow-y: scroll;padding-right: 10px;">
        <!-- APP名称 -->
        <el-form-item :label="$t('appHelpCenter.appName')" prop="appName">
          <el-input size='small' v-model="form.appName" :placeholder="$t('creditSupermarket.ruleName')"></el-input>
        </el-form-item>
        <!-- APP包名 -->
        <el-form-item :label="$t('AppUpgrade.appName')" prop="appPackageName">
          <el-input size='small' v-model="form.appPackageName" :placeholder="$t('ElectricChannel.ruleAppName')" :disabled="isDis"></el-input>
        </el-form-item>
        <!-- 版本号 -->
        <el-form-item :label="$t('AppVersion.verId')" prop="appVersion">
          <el-input size='small' v-model="form.appVersion" :placeholder="$t('AppVersion.ruleVersion')" :disabled="isDis"></el-input>
        </el-form-item>
        <!-- 渠道 -->
        <el-form-item :label="$t('productManage.channels')" prop="channel">
          <el-select v-model='form.channel' :placeholder="$t('userGroupManager.ruleChannel')" size='small' style="width: 100%;">
            <el-option
            v-for='item in appChannel'
            :key='item.id'
            :label='item.org_name'
            :value='item.channel'>
            </el-option>
          </el-select>
        </el-form-item>
        <!-- 短信签名 -->
        <el-form-item :label="$t('AppVersion.SMSsignature')" prop="smsHead">
          <el-input size='small' v-model="form.smsHead" :placeholder="$t('AppVersion.ruleSMSsign')"></el-input>
        </el-form-item>
        <!-- 订单前缀 -->
        <el-form-item :label="$t('AppVersion.OrderPrefix')" prop="orderBegin">
          <el-input size='small' v-model="form.orderBegin" :placeholder="$t('AppVersion.ruleOrderPrefix')"></el-input>
        </el-form-item>
        <!-- 验证码类型 -->
        <el-form-item :label="$t('AppVersion.IDCodeType')" prop="loginType">
          <el-select v-model="form.loginType" :placeholder="$t('AppVersion.ruleCodeType')" size='small' style="width: 100%;">
            <!-- <el-option :label="$t('AppVersion.FaceBookCode')" value="1"></el-option> -->
            <el-option v-for="item in loginTypeList" 
              :key="item.id"
              :label="item.dictValue"
              :value="item.dictCode"></el-option>
          </el-select>
        </el-form-item>
        <template v-if="form.loginType !== '2'">
          <!-- 应用编号 -->
          <el-form-item :label="$t('AppVersion.ApplyNumber')" prop="applyCode">
            <el-input size='small' v-model="form.applyCode" :placeholder="$t('AppVersion.ruleApplyNum')"></el-input>
          </el-form-item>
          <!-- 应用密钥 -->
          <el-form-item :label="$t('AppVersion.ApplyKey')" prop="applyPassword">
            <el-input size='small' v-model="form.applyPassword" :placeholder="$t('AppVersion.ruleApplyKey')"></el-input>
          </el-form-item>
        </template>  
        <!-- 认证顺序 -->
        <el-form-item :label="$t('AppVersion.AuthSequence')" prop="authOrder">
          <el-input size='small' v-model="form.authOrder" :placeholder="$t('AppVersion.ruleAuthSequence')">
            <el-button slot="append" icon="el-icon-question" @click="explainFn"></el-button>
          </el-input>
        </el-form-item>
        <!-- 是否展期 -->
        <el-form-item :label="$t('AppVersion.isExtension')" prop="rollStatus">
          <el-radio-group v-model="form.rollStatus" size='small'>
            <el-radio :label="1" size="mini">{{$t("approvalDetail.yes")}}</el-radio>
            <el-radio :label="2" size="mini">{{$t("approvalDetail.no")}}</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel('form')">{{$t('btn.cancel')}}</el-button>
        <el-button v-if="dialogStatus=='create'" type="primary" @click="create('form')">{{$t('btn.confirm')}}</el-button>
        <el-button v-else type="primary" @click="update('form')">{{$t('btn.confirm')}}</el-button>
      </div>
    </el-dialog>
    <el-dialog
      :title="$t('AppVersion.versionRecord')"
      :visible.sync="dialogVerRecordVisible"
    >
      <div>
        <el-table
          :data="versionListData"
          border
          stripe
          style="width: 100%">
          <!-- 更新时间 -->
          <el-table-column 
          header-align="center"
          align="center" 
          :label="$t('keyword.updateTime')" 
          prop="crtTime"
          width="160">
          </el-table-column>
          <!-- 版本号 -->
          <el-table-column
          header-align="center"
          align="center"
          :label="$t('AppVersion.verId')"
          prop="verId"
          width="120">
          </el-table-column>
          <!-- 更新内容 -->
          <el-table-column 
          header-align="center"
          align="center" 
          :label="$t('AppVersion.updateCont')" 
          prop="verDesc">
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>
    <div class="step">
      <el-dialog
        :title="$t('AppVersion.StepInstructions')"
        :visible.sync="dialogStepVisible"
        center
        :modal="false"
        :close-on-click-modal="false">
        <div class="cont">
          <div class="cont-item" style="border-right: 1px solid #EBEEF5;">
            <div style="padding-bottom: 5px;">
              {{$t('AppVersion.tableTitle')}}:
            </div>
            <el-table :data="stepData" border size="mini">
              <!-- 数字代号 -->
              <el-table-column header-align="center" align="center" prop="index" :label="$t('AppVersion.numCode')"></el-table-column>
              <!-- 模块 -->
              <el-table-column header-align="center" align="center" prop="module" :label="$t('AppVersion.module')"></el-table-column>
            </el-table>
          </div>
          <div class="cont-item">
            <div style="padding-bottom: 5px;">
              {{$t('AppVersion.examples')}}:
            </div>
            <div style="line-height: 20px;">
              {{$t('AppVersion.suchUs')}}：{{$t('approvalDetail.IDInfo')}}、{{$t('approvalDetail.personal')}}、{{$t('approvalDetail.work')}}、{{$t('AppVersion.PurposeLoan')}}、{{$t('approvalDetail.urgent')}}、{{$t('approvalDetail.bankCardInfo')}}、{{$t('approvalDetail.SuppleInfor')}}
              <div>{{$t('AppVersion.needInp')}}: 1234567{{$t('AppVersion.thatWillDo')}}</div>
            </div>
          </div>
        </div>
      </el-dialog>
    </div>
    <el-dialog
      :title="$t('AppVersion.EnableUpdate')"
      :visible.sync="dialogUpdateVisible"
      width="30%"
      center
      :before-close="handleClose"
    >
      <el-form :model="updateForm" :rules="updateRules" ref="updateForm" label-width="100px">
        <!-- 版本号 -->
        <el-form-item :label="$t('AppVersion.verId')" prop="verId">
          <el-input size='small' v-model="updateForm.verId" :placeholder="$t('AppVersion.interVersionNum')"></el-input>
        </el-form-item>
        <!-- 更新内容 -->
        <el-form-item :label="$t('AppVersion.updateCont')" prop="verDesc">
          <el-input size='small' v-model="updateForm.verDesc" :placeholder="$t('AppVersion.interUpdateComt')"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="updateSubmit('updateForm')">{{$t('btn.conserve')}}</el-button>
      </div>
    </el-dialog>
    <!-- 下载地址管理 -->
    <el-dialog
      :title="$t('AppVersion.PackageManage')"
      :visible.sync="packageDialogVisible"
      width="30%"
      center>
      <div style="text-align: center;padding-bottom: 20px;">
        <!-- 未上传 -->
        <div v-if="isUpload === 0">
          <el-form ref="downloadForm" :model="downloadForm">
            <el-form-item :label="$t('creditSupermarket.downloadAddress')" label-width="80px">
              <el-input size='small' v-model="downloadForm.httpUrl" :placeholder="$t('AppVersion.ruleUploadUrl')"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="pkgUploadFn('downloadForm')">{{$t('AppVersion.uploadPackage')}}</el-button>
            </el-form-item>
          </el-form>
          <!-- <p>{{$t('AppVersion.pkgNotUploaded')}}</p>
          <el-button 
            type="primary" 
            @click="pkgUploadFn" 
            v-loading.fullscreen.lock="fullscreenLoading" 
            :element-loading-text="$t('AppVersion.uploadWarn')" 
            element-loading-spinner="el-icon-loading" 
            element-loading-background="rgba(0, 0, 0, 0.8)">{{$t('AppVersion.uploadPackage')}}</el-button>
          <form action="" class="videoForm">
            <input type="file" @change='onUpload' name="file" class="hiddenInput">
          </form> -->
        </div>
        <!-- 已上传 -->
        <div v-if="isUpload === 1">
          <el-form ref="downloadForm" :model="downloadForm">
            <el-form-item :label="$t('creditSupermarket.downloadAddress')" label-width="80px">
              <el-input size='small' v-model="downloadForm.httpUrl" :placeholder="$t('AppVersion.ruleUploadUrl')"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="pkgUploadFn('downloadForm')">{{$t('AppVersion.uptPackage')}}</el-button>
            </el-form-item>
          </el-form>
          <!-- <p>{{$t('AppVersion.ruleUploadUrl')}}</span>
          <el-button 
            type="primary" 
            @click="pkgUploadFn" 
            v-loading.fullscreen.lock="fullscreenLoading" 
            :element-loading-text="$t('AppVersion.uploadWarn')"
            element-loading-spinner="el-icon-loading" 
            element-loading-background="rgba(0, 0, 0, 0.8)">{{$t('AppVersion.uptPackage')}}</el-button>
          <form action="" class="videoForm">
            <input type="file" @change='onUpload' name="file" class="hiddenInput">
          </form> -->
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { getChannels } from 'api/customQuery/index';
import { appManagePage, listAppVersion, addNewAppVersion, addAppManage, getAppManage, deleteAppManage, dealAppRollOver, getDict, uptOnlineStatus, upload, updateUrl } from "api/version/index";
export default {
  data() {
    return {
      isDis: false,
      updateForm: {
        verId: undefined,
        verDesc: undefined
      },
      updateRules: {
        verId: [{
          required: true,
          message: this.$t('AppVersion.interVersionNum'),
          trigger: 'blur'
        }],
        verDesc: [{
          required: true,
          message: this.$t('AppVersion.interUpdateComt'),
          trigger: 'blur'
        }]
      },
      dialogUpdateVisible: false,
      stepData: [
        {
          index: 1,
          module: this.$t('approvalDetail.IDInfo')
        },
        {
          index: 2,
          module: this.$t('approvalDetail.personal')
        },
        {
          index: 3,
          module: this.$t('approvalDetail.work')
        },
        {
          index: 4,
          module: this.$t('AppVersion.PurposeLoan')
        },
        {
          index: 5,
          module: this.$t('approvalDetail.urgent')
        },
        {
          index: 6,
          module: this.$t('approvalDetail.bankCardInfo')
        },
        {
          index: 7,
          module: this.$t('approvalDetail.SuppleInfor')
        }
      ],
      dialogStepVisible: false,
      dialogVerRecordVisible: false,
      versionListData: [],
      appChannel: [],
      loginTypeList: [],
      form: {
        appName: undefined,
        appPackageName: undefined,
        appVersion: undefined,
        channel: undefined,
        smsHead: undefined,
        orderBegin: undefined,
        IDCodeType: '1',
        applyCode: undefined,
        applyPassword: undefined,
        authOrder: undefined,
        rollStatus: 1,
        loginType: undefined
      },
      rules: {
        appName: [
          {
            required: true,
            message: this.$t('creditSupermarket.ruleName'),
            trigger: 'blur'
          }],
        appPackageName: [
          {
            required: true,
            message: this.$t('ElectricChannel.ruleAppName'),
            trigger: 'blur'
          },
          {
            min: 3,
            max: 50,
            message: this.$t('AppVersion.limitLen'),
            trigger: 'blur'
          },
          { validator: function(rule, value, callback) {
            if (value) {
              if (/[\u4E00-\u9FA5]/g.test(value)) {
                callback(new Error('Tidak dapat memasukkan karakter Cina'));
              } else {
                callback();
              }
            }
            callback();
          }, trigger: 'blur'}
        ],
        appVersion: [
          {
            required: true,
            message: this.$t('AppVersion.ruleVersion'),
            trigger: 'blur'
          },
          {
            min: 3,
            max: 20,
            message: this.$t('rule.length'),
            trigger: 'blur'
          }
        ],
        channel: [
          {
            required: true,
            message: this.$t('userGroupManager.ruleChannel'),
            trigger: 'change'
          }
        ],
        smsHead: [
          {
            required: true,
            message: this.$t('AppVersion.ruleSMSsign'),
            trigger: 'blur'
          }
        ],
        orderBegin: [
          {
            required: true,
            message: this.$t('AppVersion.ruleOrderPrefix'),
            trigger: 'blur'
          }
        ],
        IDCodeType: [
          {
            required: true,
            message: this.$t('AppVersion.ruleCodeType'),
            trigger: 'change'
          }
        ],
        loginType: [
          {
            required: true,
            message: this.$t('AppVersion.ruleCodeType'),
            trigger: 'change'
          }
        ],
        applyCode: [
          {
            required: true,
            message: this.$t('AppVersion.ruleApplyNum'),
            trigger: 'blur'
          }
        ],
        applyPassword: [
          {
            required: true,
            message: this.$t('AppVersion.ruleApplyKey'),
            trigger: 'blur'
          }
        ],
        authOrder: [
          {
            required: true,
            message: this.$t('AppVersion.ruleAuthSequence'),
            trigger: 'blur'
          },
          { pattern: /^(?!\d*?(\d)\d*?\1)[1-7]{7}$/, message: this.$t('AppVersion.AuthOrder') }
        ],
        rollStatus: [
          {
            required: true,
            message: this.$t('AppVersion.ruleIsExtension'),
            trigger: 'blur'
          }
        ],
      },
      dialogFormVisible: false,
      textMap: {
        create: this.$t('btn.add'),
        update: this.$t('btn.edit')
      },
      dialogStatus: '',
      listLoading: false,
      total: null,
      listQuery: {
        limit: 5,
        page: 1,
        appName: "",
        forceStatus: "",
        rolloverStatus: ""
      },
      tableData: [],
      multipleSelection: [],
      extStatusArr: [
        {
          value: "",
          label: this.$t("rule.all")
        },
        {
          value: 1,
          label: this.$t("grouping.enable")
        },
        {
          value: 0,
          label: this.$t("AppVersion.blockup")
        }
      ],
      appStatus: [
        {
          value: "",
          label: this.$t("rule.all")
        },
        {
          value: 1,
          label: this.$t("grouping.enable")
        },
        {
          value: 0,
          label: this.$t("AppVersion.blockup")
        }
      ],
      currentRow: {},
      pubStatusArr: [
        {
          value: 0,
          label: this.$t("AppVersion.Stateless")
        },
        {
          value: 1,
          label: this.$t("AppVersion.SuccessRelease")
        },
        {
          value: 2,
          label: this.$t("AppVersion.PublishFail")
        },
        {
          value: 3,
          label: this.$t("AppVersion.Undercarriage")
        },
      ],
      packageDialogVisible: false,
      isUpload: '',
      fullscreenLoading: false,
      downloadForm: {
        httpUrl: ''
      }
    };
  },
  created() {
    //渠道下拉
    getChannels()
    .then(response => {
      this.appChannel = response.data;
      this.form.channel = this.appChannel[0].channel;
    })
    if (this.appVerPage.has(this.$route.path)) {
      this.listQuery = this.appVerPage.get(this.$route.path);
    }
    // 登录类型下拉
    getDict().then(res => {
      if (res.status === 200) {
        this.loginTypeList = res.data
      }
    })
    this.getList();
  },
  computed: {
    ...mapGetters(["elements", "appVerPage"])
  },
  methods: {
    // 关闭启用更新
    handleClose(done) {
      // 调用改变状态的接口
      done();
    },
    // 点击启用更新保存
    updateSubmit(formName) {
      const set = this.$refs;
      set[formName].validate(valid => {
        if (valid) {
          this.$confirm(this.$t('loanDetail.cue1'), {
            confirmButtonText: this.$t('btn.confirm'),
            cancelButtonText: this.$t('btn.cancel'),
            type: 'warning',
            center: true
          })
            .then(() => {
              let obj = {};
              obj.updateFlag = '2';
              obj.pkName = this.currentRow.packageName;
              obj.verId = this.updateForm.verId;
              obj.verDesc = this.updateForm.verDesc;
              obj.channel = this.currentRow.channel;
              addNewAppVersion(obj).then(res => {
                if (res.status === 200) {
                  this.$message({
                    showClose: true,
                    type: "success",
                    message: this.$t("approvalDispatch.opersuccess")
                  });
                  this.dialogUpdateVisible = false;
                  this.getList();
                } else {
                  this.$message({
                    showClose: true,
                    type: "warning",
                    message: res.message
                  });
                  this.getList();
                }
              });
            })
            .catch(() => {
              this.$message({
                showClose: true,
                type: 'info',
                message: this.$t('loanDetail.cue3')
              });
            });
        } else {
          return false;
        }
      });
    },
    // 点击说明按钮
    explainFn() {
      this.dialogStepVisible = true;
    },
    // 点击版本记录按钮
    hitseeFn(row) {
      this.dialogVerRecordVisible = true;
      this.verRecordFn(row);
    },
    // 版本记录列表
    verRecordFn(row) {
      let obj = {};
      obj.packageName = row.packageName;
      listAppVersion(obj)
      .then(res => {
        this.versionListData = res;
      })
    },
    // 点击安装包管理
    packageFn(row) {
      this.downloadForm.httpUrl = row.httpUrl;
      if (row.httpUrl === '') { // 未上传
        this.isUpload = 0;
      } else if (row.httpUrl !== '') { // 已上传
        this.isUpload = 1;
      }
      this.currentRow = row;
      this.packageDialogVisible = true;
    },
    // 更新地址
    pkgUploadFn(formName) {
      const set = this.$refs;
      set[formName].validate(valid => {
        if (valid) {
          this.$confirm(this.$t('loanDetail.cue1'), {
            confirmButtonText: this.$t('btn.confirm'),
            cancelButtonText: this.$t('btn.cancel'),
            type: 'warning',
            center: true
          })
            .then(() => {
              let obj = {};
              obj.versionId = this.currentRow.versionId;
              obj.httpUrl = this.downloadForm.httpUrl;
              updateUrl(obj).then(response => {
                if (response.status === 200) {
                  this.packageDialogVisible = false;
                  this.getList();
                  this.$notify({
                    title: this.$t('user.success'),
                    message: this.$t('user.crtsuccess'),
                    type: 'success',
                    duration: 2000
                  });
                } else {
                  this.$message({
                    showClose: true,
                    type: 'warning',
                    message: response.message
                  });
                }
              });
            })
            .catch(() => {
              this.$message({
                showClose: true,
                type: 'info',
                message: this.$t('loanDetail.cue3')
              });
            });
        } else {
          return false;
        }
      });
    },
    // 上传成功后的回调
    // onUpload(e){
    //   this.fullscreenLoading = true;
    //   let $target = e.target || e.srcElement;
    //   let filename = $target.value;
    //   let suffix = filename.substring(filename.lastIndexOf('.') + 1);
    //   if (suffix !== 'apk') {
    //     this.$message({
    //       showClose: true,
    //       type: "warning",
    //       message: this.$t('creditSupermarket.suffixRule')
    //     });
    //     document.getElementsByName("videoForm") && document.getElementsByName("videoForm").reset();
    //   } else {
    //     let file = $target.files[0];
    //     if ( file === undefined || file === null || file === '') {
    //       return;
    //     }
    //     const obj = new FormData();
    //     obj.append('apk', file);
    //     upload(this.currentRow.packageName, obj)
    //     .then(res => {
    //       if (res.status === 200) {
    //         this.$message({
    //           showClose: true,
    //           type: "success",
    //           message: this.$t('rule.uploadSus')
    //         });
    //         this.fullscreenLoading = false;
    //         this.packageDialogVisible = false;
    //         this.getList();
    //       } else {
    //         this.$message({
    //           showClose: true,
    //           type: "warning",
    //           message: res.message
    //         });
    //       }
    //     })
    //   }
    // },
    // 是否展期
    changeStatus(row) {
      let obj = {};
      obj.appPackageName = row.packageName;
      if (row.rolloverStatus === 0) {
        obj.rollStatus = 2;
      } else {
        obj.rollStatus = row.rolloverStatus;
      }
      dealAppRollOver(obj).then(res => {
        if (res.status === 200) {
          this.$message({
            showClose: true,
            type: "success",
            message: this.$t("approvalDispatch.opersuccess")
          });
          this.getList();
        } else {
          this.$message({
            showClose: true,
            type: "warning",
            message: res.message
          });
          this.getList();
        }
      });
    },
    // 强更状态
    changeStatusUpdate(row) {
      this.currentRow = row;
      if (row.forceStatus === 1) {
        this.updateForm = {
          verId: undefined,
          verDesc: undefined
        }
        this.dialogUpdateVisible = true;
        this.getList();
      } else if (row.forceStatus === 0) {
        this.dialogUpdateVisible = false;
        let obj = {};
        obj.updateFlag = '1';
        obj.pkName = row.packageName;
        addNewAppVersion(obj).then(res => {
          if (res.status === 200) {
            this.$message({
              showClose: true,
              type: "success",
              message: this.$t("approvalDispatch.opersuccess")
            });
            this.getList();
          } else {
            this.$message({
              showClose: true,
              type: "warning",
              message: res.message
            });
            this.getList();
          }
        });
      }
    },
    // 发布状态
    changeStatusPublish(row) {
      let obj = {};
      obj.onlineStatus = row.onlineStatus;
      uptOnlineStatus(row.id, obj).then(res => {
        if (res.status === 200) {
          this.$message({
            showClose: true,
            type: "success",
            message: this.$t("department.editsuccess")
          });
          this.getList();
        } else {
          this.$message({
            showClose: true,
            type: "warning",
            message: res.message
          });
          this.getList();
        }
      });
    },
    resetTemp() {
      this.form = {
        appName: undefined,
        appPackageName: undefined,
        appVersion: undefined,
        channel: this.appChannel[0].channel,
        smsHead: undefined,
        orderBegin: undefined,
        IDCodeType: '1',
        applyCode: undefined,
        applyPassword: undefined,
        authOrder: undefined,
        rollStatus: 1,
        loginType: undefined
      };
    },
    closeDialog(done) {
      done();
      this.$refs["form"].resetFields();
    },
    // 点击添加按钮
    handleCreate() {
      this.resetTemp();
      this.dialogStatus = 'create';
      this.isDis = false;
      this.dialogFormVisible = true;
    },
    // 点击编辑按钮
    handleUpdate(row) {
      this.dialogStatus = 'update';
      this.isDis = true;
      let obj = {};
      obj.appPackageName = row.packageName;
      obj.channel = row.channel;
      getAppManage(obj)
      .then(res => {
        if (res.status === 200) {
          this.form.appName = row.appName;
          this.form.appPackageName = res.data.appPackageName;
          this.form.appVersion = row.verId;
          this.form.channel = row.channel;
          this.form.smsHead = res.data.smsHead;
          this.form.orderBegin = res.data.orderBegin;
          this.form.IDCodeType = '1';
          this.form.loginType = res.data.loginType + ''
          this.form.applyCode = res.data.applyCode;
          this.form.applyPassword = res.data.applyPassword;
          this.form.authOrder = res.data.authOrder;
          if (row.rolloverStatus === 0) {
            this.form.rollStatus = 2;
          } else {
            this.form.rollStatus = row.rolloverStatus;
          }
          this.dialogFormVisible = true;
        } else {
          this.$message({
            showClose: true,
            type: 'warning',
            message: res.message
          });
        }
      })
    },
    cancel(formName) {
      this.dialogFormVisible = false;
      this.$refs[formName].resetFields();
    },
    // 添加保存按钮
    create(formName) {
      const set = this.$refs;
      set[formName].validate(valid => {
        if (valid) {
          this.$confirm(this.$t('loanDetail.cue1'), {
            confirmButtonText: this.$t('btn.confirm'),
            cancelButtonText: this.$t('btn.cancel'),
            type: 'warning',
            center: true
          })
            .then(() => {
              this.form.addOrUpdate = 1;
              addAppManage(this.form).then(response => {
                if (response.status === 200) {
                  this.dialogFormVisible = false;
                  this.getList();
                  this.$notify({
                    title: this.$t('user.success'),
                    message: this.$t('user.crtsuccess'),
                    type: 'success',
                    duration: 2000
                  });
                } else {
                  this.$message({
                    showClose: true,
                    type: 'warning',
                    message: response.message
                  });
                }
              });
            })
            .catch(() => {
              this.$message({
                showClose: true,
                type: 'info',
                message: this.$t('loanDetail.cue3')
              });
            });
        } else {
          return false;
        }
      });
    },
    // 编辑保存按钮
    update(formName) {
      const set = this.$refs;
      set[formName].validate(valid => {
        if (valid) {
          this.$confirm(this.$t('loanDetail.cue1'), {
            confirmButtonText: this.$t('btn.confirm'),
            cancelButtonText: this.$t('btn.cancel'),
            type: 'warning',
            center: true
          })
            .then(() => {
              this.form.addOrUpdate = 2;
              addAppManage(this.form).then(response => {
                if (response.status === 200) {
                  this.dialogFormVisible = false;
                  this.getList();
                  this.$notify({
                    title: this.$t('user.success'),
                    message: this.$t('wordbook.wbeditsuc'),
                    type: 'success',
                    duration: 2000
                  });
                } else {
                  this.$message({
                    showClose: true,
                    type: 'warning',
                    message: response.message
                  });
                }
              });
            })
            .catch(() => {
              this.$message({
                showClose: true,
                type: 'info',
                message: this.$t('loanDetail.cue3')
              });
            });
        } else {
          return false;
        }
      });
    },
    // 点击删除按钮
    handleDelete(row) {
      this.$confirm(this.$t('user.cue1'), this.$t('user.cue2'), {
        confirmButtonText: this.$t('btn.confirm'),
        cancelButtonText: this.$t('btn.cancel'),
        type: 'warning'
      })
        .then(() => {
          let obj = {};
          obj.appPackageName = row.packageName;
          deleteAppManage(obj)
            .then(() => {
              this.$notify({
                title: this.$t('user.success'),
                message: this.$t('user.delsuccess'),
                type: 'success',
                duration: 2000
              });
              this.getList();
            });
        }).catch(() => {
        this.$message({
          showClose: true,
          type: "info",
          message: this.$t("orderQuery.cue2")
        });
      });
    },
    getList() {
      this.listLoading = true;
      this.$store.dispatch("saveAppVerPage", {
        path: this.$route.path,
        listQuery: this.listQuery
      });
      appManagePage(this.listQuery).then(response => {
        if (response.status === 200) {
          this.listLoading = false;
          this.tableData = response.data.rows;
          this.total = Number(response.data.total);
        } else {
          this.$message({
            showClose: true,
            type: 'warning',
            message: response.message
          });
        }
      });
    },
    // 查询
    search() {
      this.listQuery.page = 1;
      this.getList();
    },
    // 选中的数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      this.listQuery.limit = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.page = val;
      this.getList();
    }
  }
};
</script>

<style scoped lang='scss'>
.box-card {
  width: 95%;
  margin-left: 2.5%;
  margin-right: 2.5%;
}
.title {
  line-height: 30px;
  font-size: 16px;
  display: flex;
  align-items: center;
  font-weight: bold;
}
.title:before {
  display: block;
  content: "";
  width: 3px;
  height: 16px;
  background-color: #309afe;
}
.title:before {
  margin-right: 8px;
}
::before {
  box-sizing: inherit;
  -webkit-tap-highlight-color: transparent;
}
.menu-title {
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  .searchItem {
    display: flex;
    align-items: center;
    padding: 10px 0;
    span {
      display: inline-block;
      width: 100px;
      text-align: right;
      font-size: 12px;
      color: #5f5f61;
      padding-right: 5px;
    }
    div:nth-child(2) {
      width: 180px;
    }
  }
  .searchItem-date {
    display: flex;
    align-items: center;
    padding: 10px 0;
    b {
      margin: 0 10px;
      font-weight: normal;
      font-size: 12px;
      color: #5f5f61;
    }
    div {
      width: 180px;
    }
  }
}
.menu-title-btn {
  padding: 10px 0;
  box-sizing: border-box;
  button {
    padding: 0 20px;
    height: 28px;
    background: #20a0ff;
    color: #fff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
    &:nth-child(1) {
      margin-left: 0;
    }
    &:nth-child(2) {
      background: #ebf5ff;
      color: #20a0ff;
      border: 1px solid #abd5ff;
    }
  }
  button[disabled] {
    padding: 0 20px;
    height: 28px;
    background: #c1e0ff;
    color: #fafbff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
  }
}
.menu-list {
  button {
    padding: 0 20px;
    height: 28px;
    background: #20a0ff;
    color: #fff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
    &:nth-child(1) {
      margin-left: 0;
    }
  }
  button[disabled] {
    padding: 0 20px;
    height: 28px;
    background: #c1e0ff;
    color: #fafbff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
  }
}
.href {
  border-bottom: 1px solid #000;
  cursor: pointer;
  &:hover {
    color: #20a0ff;
    border-bottom: 1px solid #20a0ff;
  }
}

.able {
  display: inline-block;
  span {
    border-bottom: 1px solid #afb0b2;
    padding-bottom: 2px;
    color: #afb0b2;
    cursor: pointer;
  }
}
.step /deep/.el-dialog {
  width: 400px;
}
.step /deep/.el-dialog--center .el-dialog__body {
    text-align: initial;
    padding: 0;
}
.step /deep/.el-dialog__title {
  font-size: 14px;
}
.step /deep/.el-dialog__header {
    padding: 10px 10px 5px;
}
.step /deep/.el-dialog__headerbtn {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 0;
    background: 0 0;
    border: none;
    outline: 0;
    cursor: pointer;
    font-size: 16px;
}
.step .cont {
  display: flex;
  border-top: 1px solid #EBEEF5;
}
.step .cont .cont-item {
  width: 50%;
  padding: 5px 5px 10px;
  font-size: 12px;
}
.hiddenInput{
  display: none;
}
</style>